<template>
	<div class="body">
		<!-- 用户名修改  -->
		<!-- <div class="header">
			<div>
				<img @click="returnGo" src="../../assets/homeimg/滑动左.png" />
				<span>用户名</span>
			</div>
		</div> -->
		<div class="min">
			<div class="username">
				<input type="text" maxlength="10" style="flex:1;background-color:#f7f7f7" placeholder="" v-model="username" />
			</div>
			<div class="Savename" @click="savename">
				保存
			</div>
		
		</div>
	</div>
</template>
<script>
	import mineApi from "@/api/mine";
	export default {
		data() {
			return {
				username: '',
				token:'',
				userdata:{}
			};
		},
		created() {
			// if (localStorage.getItem("userInfo")) {
			// 	this.userdata = JSON.parse(localStorage.getItem("userInfo"));
			// }
			this.username = this.$route.query.name;
		},
		components: {
			// [Image.name]: Image
		},
		methods: {
			returnGo() {
				this.$router.go(-1);
			},
			savename() {
				this.userdata.nickname = this.username;
				// this.$toast.success({
				// 	message:this.userdata.nickname
				// });
				this.$http.post('/api/user/profile',{nickname:this.username}).then(res => {
					if(res.code==1){
						this.$toast.success({
							message:'修改成功'
							// message:this.userdata
						});
						 window.h5_android && window.h5_android.postName(this.username);
						 this.$router.back()
						// window.webkit.messageHandlers.userInfoChange_js_oc.postMessage([this.userdata])
					}
				})
			}
		}
	};
</script>
<style lang="scss" scoped="scoped">
	.body {
		color: #333333;
		height: 100%;
		display: flex;
		flex-direction: column;
	}

	.header {
		// font-weight: bold;
		width: 100%;
		text-align: center;
		height: 2.75rem;
		line-height: 2.75rem;
		padding-top: 1.25rem;
		position: relative;
		border-bottom: 1px solid #dcdcdc;
		color: #333333;
		font-size: 1.25rem;

		img {
			width: 0.625rem;
			height: 1.125rem;
			position: absolute;
			left: 1rem;
			bottom: 0.75rem;
		}
	}
// 在scss文件中
	@supports(bottom:constant(safe-area-inset-top)) {

		// 如果存在底部安全区域
		.header {
			padding-top: constant(safe-area-inset-top);

		}

	}

	@supports(bottom:env(safe-area-inset-top)) {

		// 如果存在底部安全区域
		.header {
			padding-top: env(safe-area-inset-top);

		}

	}
	.username {
		height: 2.5rem;
		line-height: 0.625rem;
		color: #333333;
		font-size: 1rem;
		padding-left: 1.25rem;
		border-bottom: 1px solid #dcdcdc;
		display: flex;
		align-items: center;
		justify-content: flex-start;

		input {
			height: 2rem;
			border: 0;
			outline: medium;
		}
	}

	.Savename {
		width: 18.75rem;
		height: 2.75rem;
		background: #ffb209;
		text-align: center;
		line-height: 2.75rem;
		border-radius: 1.375rem;
		margin: 0 auto;
		margin-top: 10.625rem;
		font-size: 1.125rem;
		color: #fff;
	}
</style>
